package com.chen.controller.admin;

import com.chen.common.result.Result;
import com.chen.popj.dto.ProblemDTO;
import com.chen.popj.entity.Problem;
import com.chen.service.ElasticSearchService;
import com.chen.service.ProblemService;
import com.chen.service.impl.ElasticSearchServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController(value = "adminProblemController")
@Slf4j
@RequestMapping("/admin")
public class ProblemController {

    @Autowired
    ProblemService problemService;

    /**
     * 添加题目
     *
     * @param problemDTO
     * @return
     */
    @PostMapping("/add")
    public Result addProblem(@RequestBody ProblemDTO problemDTO) {
        problemService.addProblem(problemDTO);
        return Result.success();
    }

    /**
     * 根据题目id删除题目
     *
     * @param ids
     * @return
     */
    @DeleteMapping("/delete")
    public Result<Object> deleteProblem(@RequestBody ArrayList<Integer> ids) {
        problemService.delete(ids);
        return Result.success();
    }
}
